package com.offcn.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RefreshScope
public class ProviderController {

    @Value("${myName}")
    private String myName;

    @Value("${redis.url}")
    private String redisUrl;
    @Value("${jdbc.url}")
    private String jdbcUrl;

    @RequestMapping("hello")
    public String hello(HttpServletRequest request){
        //获取name叫myhead的请求头
        String myhead = request.getHeader("myhead8");
        System.out.printf("获取到的请求头的值:"+myhead);

        String foo = request.getParameter("foo");
        System.out.printf("获取到请求参数:"+foo);
        //int i=1/0;
        return "Hello "+myName+" redis:"+redisUrl+" jdbc:"+jdbcUrl;
    }
}
